<html>
<head><meta charset="utf-8"><title>Mutation points · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html">Mutation points</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205741176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741176">(Aug 02 2020 at 19:44)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> I also ran with your mutation points idea today and this is what I've come up with so far: <a href="/user_uploads/4715/NX2MqcZzB0MNsyFCvUxTAMKp/Screenshot-from-2020-08-02-15-41-44.png">Screenshot-from-2020-08-02-15-41-44.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/NX2MqcZzB0MNsyFCvUxTAMKp/Screenshot-from-2020-08-02-15-41-44.png" title="Screenshot-from-2020-08-02-15-41-44.png"><img src="/user_uploads/4715/NX2MqcZzB0MNsyFCvUxTAMKp/Screenshot-from-2020-08-02-15-41-44.png"></a></div><p>In this test, I changed <code>mutable</code> to just be bold, and <code>mutation</code> to have the underlines. Does it make sense to add the <code>mutation</code> modifier to ever name within the expr? I currently have it set to do that for all names/name ref in the lhs of an assignment expr, and in the expr of all method call expr where the self is <code>&amp;mut</code>.</p>



<a name="205741234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741234">(Aug 02 2020 at 19:45)</a>:</h4>
<p>Though I feel like such an algorithm falls apart if you have some kind of temporary. Something like <code>(Struct {x: 5, g: 4}).mutation_fn().some_result</code> would have the names in the temporary incorrectly highlighted. I'm not sure what to do for those kinds of cases.</p>



<a name="205741291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741291">(Aug 02 2020 at 19:46)</a>:</h4>
<p>Hm, I wonder it makes sense to underling <em>function call</em> instead</p>



<a name="205741295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741295">(Aug 02 2020 at 19:46)</a>:</h4>
<p>That way, you'll be able to intuitively re-use underlining</p>



<a name="205741312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741312">(Aug 02 2020 at 19:47)</a>:</h4>
<div class="codehilite"><pre><span></span><code>let mut *x* = ....;

*x*.foo();
*x*.*bar*();
</code></pre></div>



<a name="205741366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741366">(Aug 02 2020 at 19:48)</a>:</h4>
<p>I <em>think</em> <code>(&amp;mut self)</code> methods is probably the single place where  mutation happens implicitly, so maybe only highlight it</p>



<a name="205741374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741374">(Aug 02 2020 at 19:48)</a>:</h4>
<p>as in, <code>&amp;mut some_var</code> is already syntactically visible</p>



<a name="205741759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741759">(Aug 02 2020 at 19:59)</a>:</h4>
<p>Oh, that's already done in the PR in the other thread. I thought you had mentioned wanting to also highlight mutation points separately</p>



<a name="205741766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741766">(Aug 02 2020 at 19:59)</a>:</h4>
<p>Copying here so no one needs to jump around: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/5643">https://github.com/rust-analyzer/rust-analyzer/pull/5643</a></p>



<a name="205741819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Mutation%20points/near/205741819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Mutation.20points.html#205741819">(Aug 02 2020 at 20:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Adding.20mut.2Fowning.20semantic.20modifiers.20for.20fns/near/205482863">said</a>:</p>
<blockquote>
<p>(there's more general idea of highlighing not mutable types, but rather mutation points)</p>
</blockquote>
<p>This is the comment I was referring to.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>